package question3;

import java.util.ArrayList;
import java.util.List;

public class School {
    private String name;
    private List<Department> departments = new ArrayList<>();
    private List<Student> students = new ArrayList<>();

    public School(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    // 添加系
    public void addDepartment(Department department) {
        departments.add(department);
        department.setSchool(this); // 设置系的学院为该学院
    }

    // 添加学生
    public void addStudent(Student student) {
        students.add(student);
        student.setSchool(this);    // 设置学生的学院为该学院
    }

    // 获取学院的系
    public List<Department> getDepartments() {
        return departments;
    }

    // 获取学院的学生
    public List<Student> getStudents() {
        return students;
    }
}
